import { Bot } from 'mirai-js'
import appConfig from './config/app.config'
import { botModule } from './modules'
const bot = new Bot()
const botconfig = {
  baseUrl: appConfig.BASE_URL,
  verifyKey: appConfig.VERIFYKEY,
  qq: Number(appConfig.QQ),
}
const bootstrap = async () => {
  // 判断mirai-console 服务是否登录
  const isLogin = await Bot.isBotLoggedIn({ ...botconfig })
  if (isLogin) {
    console.log('登录成功')
  } else {
    console.log('登录失败')
    return
  }
  // 链接
  await bot.open({
    ...botconfig,
  })
  console.log('启动成功')
  // 执行模块方法
  botModule(bot)
}
export default bootstrap
